//
//  HeadOwnerInfoView.m
//  PhongThuyHuongNha
//
//  Created by Le Anh Tai on 10/5/13.
//  Copyright (c) 2013 Le Anh Tai. All rights reserved.
//

#import "HeaderResultView.h"
#import "UIConstants.h"
#import "Utility.h"

@implementation HeaderResultView

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self)
    {
        self.backgroundColor = [UIColor clearColor];
        
        //title
        _titleLabel = [[UILabel alloc] init];
        _titleLabel.textAlignment = NSTextAlignmentCenter;
        _titleLabel.font = FONT_HELVETICANEUE(FONT_SIZE_HEADER_RESULT);
        _titleLabel.textColor = COLOR_BLACK_PURE;
        _titleLabel.backgroundColor = [UIColor clearColor];
        [self addSubview:_titleLabel];
        
        //owner info
        _ownerInfoTextView = [[UITextView alloc] init];
        _ownerInfoTextView.backgroundColor = [UIColor clearColor];
        _ownerInfoTextView.font = FONT_HELVETICANEUE(FONT_SIZE_HEADER_RESULT-2);
        _ownerInfoTextView.textColor = COLOR_BLACK_PURE;
        _ownerInfoTextView.editable = NO;
        _ownerInfoTextView.textAlignment = NSTextAlignmentCenter;
        _ownerInfoTextView.scrollEnabled = NO;
        [self addSubview:_ownerInfoTextView];
    }
    return self;
}

- (void)loadOwnerInfo:(NSString*)info
{
    _ownerInfoTextView.text = info;
}

- (void)setFrame:(CGRect)frame
{
    _titleLabel.frame = RECT(0, 0, frame.size.width, 30);
    CGSize size = [Utility getSizeOfString:_ownerInfoTextView.text font:_ownerInfoTextView.font width:frame.size.width - 40];
    _ownerInfoTextView.frame = RECT(15, _titleLabel.bottom, self.width - 30, size.height + 20);
    
    frame.size.height = _ownerInfoTextView.bottom;
    
    [super setFrame:frame];
}

@end
